package com.example.mall.user.svc.app.cmd;

import com.example.mall.user.svc.infr.constants.LoginModeType;
import com.example.mall.user.svc.domain.model.entity.User;
import com.example.mall.user.svc.domain.model.vo.LoginMode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Collections;

/**
 * @author Mickey
 * @since 2022/4/15
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CreateUserCmd {

    private String username;
    private String password;
    public User converterToUser() {
        User user = new User();
        user.setUsername(this.getUsername());
        user.setPassword(this.getPassword());
        user.setLoginModes(Collections.singletonList(new LoginMode(this.getUsername(), LoginModeType.USERNAME_PASSWORD)));
        return user;
    }
}
